﻿using System;
using System.Collections.Generic;
using System.Linq;

namespace BLL
{
    /// <summary>
    /// BLL to User table
    /// </summary>
    public class UserBLL : DAL.UserDAL
    {
        #region Contansts
        #endregion

        #region Objects
        #endregion

        #region Properties
        #endregion

        #region Constructors
        public UserBLL() { }
        public UserBLL(string connectString) : base(connectString) { }
        #endregion

        #region Implements
        #endregion

        #region Events
        #endregion

        #region Methods
        public UTL.Session CheckLogin(string id, string pass)
        {
            var usr = (DAL.tb_User)GetByKey(id);
            var sss = new UTL.Session();
            if (usr != null)
            {
                sss.Login = usr.Pass == pass ? true : false;
                sss.Id = usr.Id;
                sss.Pass = usr.Pass;
                sss.Name = usr.Name;
                sss.Role = (UTL.Session.Roles)usr.Role;
                sss.Current = CurrentTime; // get current time form server
            }
            else sss.Login = false;
            return sss;
        }
        #endregion

        #region Overrides
        #endregion

        #region Statics
        #endregion

        #region More
        #endregion
    }
}